package com.shinaier.laundry.snlstore.network.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * Created by 张家洛 on 2017/3/17.
 */

public class EditItemShowEntities implements Parcelable{
    @SerializedName("type")
    private List<Item> items;
    @SerializedName("type_name")
    private String typeName;

    protected EditItemShowEntities(Parcel in) {
        items = in.createTypedArrayList(Item.CREATOR);
        typeName = in.readString();
    }

    public static final Creator<EditItemShowEntities> CREATOR = new Creator<EditItemShowEntities>() {
        @Override
        public EditItemShowEntities createFromParcel(Parcel in) {
            return new EditItemShowEntities(in);
        }

        @Override
        public EditItemShowEntities[] newArray(int size) {
            return new EditItemShowEntities[size];
        }
    };

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(items);
        dest.writeString(typeName);
    }

    public static class Item implements Parcelable{
        @SerializedName("cycle") //洗护周期
        private String cycle;
        @SerializedName("id")
        private String id;
        @SerializedName("name")
        private String name;
        @SerializedName("price")
        private String price;
        @SerializedName("state")
        private String state;
        @SerializedName("state_type")
        private int stateType;
        @SerializedName("num")
        private int num;

        protected Item(Parcel in) {
            cycle = in.readString();
            id = in.readString();
            name = in.readString();
            price = in.readString();
            state = in.readString();
            stateType = in.readInt();
            num = in.readInt();
            isSelect = in.readByte() != 0;
            number = in.readInt();
            extraFrom = in.readByte() != 0;
        }

        public static final Creator<Item> CREATOR = new Creator<Item>() {
            @Override
            public Item createFromParcel(Parcel in) {
                return new Item(in);
            }

            @Override
            public Item[] newArray(int size) {
                return new Item[size];
            }
        };

        public int getStateType() {
            return stateType;
        }

        public void setStateType(int stateType) {
            this.stateType = stateType;
        }

        public int getNum() {
            return num;
        }

        public void setNum(int num) {
            this.num = num;
        }

        public boolean isSelect = false;

        private int number;

        public boolean extraFrom = true;

        public int getNumber() {
            return number;
        }

        public void setNumber(int number) {
            this.number = number;
        }

        public String getCycle() {
            return cycle;
        }

        public void setCycle(String cycle) {
            this.cycle = cycle;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getState() {
            return state;
        }

        public void setState(String state) {
            this.state = state;
        }

        @Override
        public String toString() {
            return "Item{" +
                    "cycle='" + cycle + '\'' +
                    ", id='" + id + '\'' +
                    ", name='" + name + '\'' +
                    ", price='" + price + '\'' +
                    ", state='" + state + '\'' +
                    ", number=" + number +
                    '}';
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(cycle);
            dest.writeString(id);
            dest.writeString(name);
            dest.writeString(price);
            dest.writeString(state);
            dest.writeInt(stateType);
            dest.writeInt(num);
            dest.writeByte((byte) (isSelect ? 1 : 0));
            dest.writeInt(number);
            dest.writeByte((byte) (extraFrom ? 1 : 0));
        }
    }
}
